﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BSCMFF.Core.DataAccessLayer
{
    /// <summary>
    /// 
    /// </summary>
    /// <remarks></remarks>
    public partial class Personal_KPI
    {
        /// <summary>
        /// Gets the percentage.
        /// </summary>
        /// <remarks></remarks>
        public string Percentage 
        { 
            get
            {
                string p;
                if (this.StartValue != null && this.TargetValue != null)
                {
                    double start = (double)this.StartValue;
                    double target = (double)this.TargetValue;

                    if (start != target)
                    {
                        double current = this.CurrentValue == null ? start : (double)this.CurrentValue;
                        p = ((int)(((current - start) * 100 / (target - start)))).ToString();
                    }
                    else
                    {
                        p = "0";
                    }
                }
                else
                {
                    p = "0";
                }

                return p + "%";
            }
        }
    }
}
